/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package main.java.cn.webrx;

import java.io.File;
import java.io.FileInputStream;

/**
 * <p>Project: jse2204 - Ex2
 * <p>Powered by webrx On 2022-09-22 10:55:05
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex2 {
    public static void main(String[] args) {

        System.out.println(isSame("c:/abc/a.zip","c:/abc/bc.mp4"));
    }

    public static boolean isSame(String src, String dst) {
        return isSame(new File(src), new File(dst));
    }

    public static boolean isSame(File src, File dst) {
        boolean f = false;
        if (src.length() == dst.length()) {
            try (var issrc = new FileInputStream(src); var isdst = new FileInputStream(dst)) {
                int num = 0;
                while (issrc.read() == isdst.read()) {
                    ++num;
                    if (num == src.length()) {
                        f = true;
                        break;
                    }
                }
            } catch (Exception e) {
            }
        }
        return f;
    }
}
